package com.xxxx.portal.controller;

import com.xxxx.api.pojo.GoodsVo;
import com.xxxx.api.utils.EgoPageInfo;
import com.xxxx.portal.service.SearchService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 搜索Controller
 */
@Controller
@RequestMapping("search")
public class SearchController {
    @Resource
    private SearchService searchService;

    /**
     *
     * @param searchStr
     * @param model
     * @return
     */
    @RequestMapping("index")
    public String index(String searchStr,Model model) {
        model.addAttribute("searchStr",searchStr);
        return "search/doSearch";
    }
    //http://localhost:9091/shop-portal/search/index?searchStr=%E6%89%8B%E6%9C%BA&x=31&y=6

    @RequestMapping("searchGoods")
    @ResponseBody
    public EgoPageInfo<GoodsVo> searchGoods(String searchStr, Integer pageNum, Integer pageSize) {
       return searchService.doSearch(searchStr,pageNum,pageSize);
    }
}
